<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script src="jquery.min.js"></script>
    <script>
        var val = window.prompt('准备干吗呢')
        var p = new Promise(function (resolve, reject) {
            setTimeout(function () {
                if (val == '洗菜做饭') {
                    resolve(val)
                } else {
                    reject('出去吃饭')
                }

            }, 1000)
        })

        //顺序执行
        p.then(function (res) {

            // console.log(res);

            return new Promise(function (resolve, reject) {

                setTimeout(function () {

                    resolve('坐下吃饭')

                }, 1000)
            })

        }, function (err) {

            console.log(err);

        }).then(function (res) {

            console.log(res);
        })

        p.then(function (res) {

                console.log(res);

                return new Promise(function (resolve, reject) {

                    setTimeout(function () {

                        resolve('收拾桌子，洗碗')
                    }, 1000)
                })
            }, function (err) {

                console.log(err);
            })

            .then(function (res) {
                
                console.log(res);
            })
    </script>
</body>

</html>